package com.sxfq.loansupermarket.backsystem.modular.sharesHolding.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.core.shiro.ShiroKit;
import com.sxfq.loansupermarket.backsystem.core.util.StringUtil;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.dao.DentalImageDao;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.entity.QualityAssuranceInfo;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.entity.SearchQualityAssuranceInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sxfq.loansupermarket.backsystem.modular.sharesHolding.service.ISharesHoldingService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 质量管理Dao
 *
 * @author fengshuonan
 * @Date 2019-09-01 15:34:05
 */
@Service
public class SharesHoldingServiceImpl implements ISharesHoldingService {
    @Autowired
    private DentalImageDao dao;

    @Override
    public List<QualityAssuranceInfo> selectPageListByQuality(Page<QualityAssuranceInfo> page, SearchQualityAssuranceInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartUploadTime())) {
            params.put("startUploadTime", searchInfo.getStartUploadTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndUploadTime())) {
            params.put("endUploadTime", searchInfo.getEndUploadTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getAddName())) {
            params.put("addName", searchInfo.getAddName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        params.put("pay_service_info", ShiroKit.getUser().getPay_service_info());
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getQueryPages(page, params);
    }

    @Override
    public int getQueryPageCount(Page<QualityAssuranceInfo> page, SearchQualityAssuranceInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartUploadTime())) {
            params.put("startUploadTime", searchInfo.getStartUploadTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndUploadTime())) {
            params.put("endUploadTime", searchInfo.getEndUploadTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getAddName())) {
            params.put("addName", searchInfo.getAddName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        params.put("pay_service_info", ShiroKit.getUser().getPay_service_info());
        return dao.getQueryPageCount(page, params);
    }
}
